package com.android.lovely.ui.widget

import android.content.Context
import android.graphics.Color
import android.util.AttributeSet
import android.view.View
import android.view.ViewGroup
import android.widget.EditText
import android.widget.NumberPicker
import com.kotlin.extensions.dimen.Dimension.sp


/**
 *
 * @author why
 * @date 2025/3/13 20:10
 */
class LovelyNumberPicker : NumberPicker {
    constructor(context: Context?) : super(context)

    constructor(context: Context?, attrs: AttributeSet?) : super(context, attrs)

    constructor(context: Context?, attrs: AttributeSet?, defStyleAttr: Int) : super(
        context,
        attrs,
        defStyleAttr
    )


    override fun addView(child: View) {
        super.addView(child)
        updateView(child)
    }

    override fun addView(child: View, width: Int, height: Int) {
        super.addView(child, width, height)
        updateView(child)
    }

    override fun addView(child: View, index: Int, params: ViewGroup.LayoutParams) {
        super.addView(child, index, params)
        updateView(child)
    }

    override fun addView(child: View, params: ViewGroup.LayoutParams) {
        super.addView(child, params)
        updateView(child)
    }

    fun updateView(view: View?) {
        if (view is EditText) {
            //这里修改显示字体的属性，主要修改颜色和大小
            view.setTextColor(Color.parseColor("#7673FE"))
            view.textSize = 20f
        }
    }
}
